package com.prototype.demo.deepclone;

import java.io.*;

/**
 * Created by Administrator on 2017/6/8.
 */
public class WeekLog implements Serializable{
    private Attachment attachment;
    private String name;
    private String date;
    private String content;

    public void setAttachment(Attachment attachment) {
        this.attachment = attachment;
    }
    public void setName(String name) {
        this.name = name;
    }
    public void setDate(String date) {
        this.date = date;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Attachment getAttachment(){
        return (this.attachment);
    }
    public String getName() {
        return (this.name);
    }
    public String getDate() {
        return (this.date);
    }
    public String getContent() {
        return (this.content);
    }
    //将对象写入流中
    public com.prototype.demo.deepclone.WeekLog deepClone() throws IOException,ClassNotFoundException{
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bao);
        oos.writeObject(this);

        //将写入流中的对象读取出来
        ByteArrayInputStream bai = new ByteArrayInputStream(bao.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bai);
        return (WeekLog)ois.readObject();
    }
}
